<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
    <script src="../../../resources/js-test.js"></script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
    var resetWidth;
    var resetHeight;
    var resetX;
    var resetY;

    var width = 100;
    var height = 200;
    var x = 25;
    var y = 50;

    function reset()
    {
        window.moveTo(screen.availLeft + 100, screen.availTop + 100);
        window.resizeTo(300, 200);
        resetWidth = window.outerWidth;
        resetHeight = window.outerHeight;
        resetX = window.screenX;
        resetY = window.screenY;
    }

    if (window.testRunner)
        testRunner.dumpAsText();

    reset();

    description("This test makes sure that calling the window moving and resizing\
    methods with less than 2 arguments treats the missing arguments as 0.");

    // resizeTo /////////////////////////
    debug('');
    debug('window.resizeTo Tests');
    debug('');

    debug("Testing - resizeTo with 0 arguments");
    shouldThrow('window.resizeTo()');
    shouldBe('window.outerWidth', 'resetWidth');
    shouldBe('window.outerHeight', 'resetHeight');
    reset();

    debug("Testing - resizeTo with 1 argument");
    shouldThrow('window.resizeTo(width)');
    shouldBe('window.outerWidth', 'resetWidth');
    shouldBe('window.outerHeight', 'resetHeight');
    reset();

    debug("Testing - resizeTo with more than 2 arguments");
    window.resizeTo(width, height, 200, "text");
    shouldBe('window.outerWidth', 'width');
    shouldBe('window.outerHeight', 'height');
    reset();

    // resizeBy /////////////////////////
    debug('');
    debug('window.resizeBy Tests');
    debug('');

    debug("Testing - resizeBy with 0 arguments");
    shouldThrow('window.resizeBy()');
    shouldBe('window.outerWidth', 'resetWidth');
    shouldBe('window.outerHeight', 'resetHeight');
    reset();

    debug("Testing - resizeBy with 1 argument");
    shouldThrow('window.resizeBy(x)');
    shouldBe('window.outerWidth', 'resetWidth');
    shouldBe('window.outerHeight', 'resetHeight');
    reset();

    debug("Testing - resizeBy with more than 2 arguments");
    window.resizeBy(x, y, 200, "text");
    shouldBe('window.outerWidth', 'resetWidth + x');
    shouldBe('window.outerHeight', 'resetHeight + y');
    reset();


    // moveTo /////////////////////////
    debug('');
    debug('window.moveTo Tests');
    debug('');

    debug("Testing - moveTo with 0 arguments");
    shouldThrow('window.moveTo()');
    shouldBe('window.screenX', 'resetX');
    shouldBe('window.screenY', 'resetY');
    reset();

    debug("Testing - moveTo with 1 argument");
    shouldThrow('window.moveTo(x)');
    shouldBe('window.screenX', 'resetX');
    shouldBe('window.screenY', 'resetY');
    reset();

    debug("Testing - moveTo with more than 2 arguments");
    window.moveTo(x, y, 200, "text");
    shouldBe('window.screenX', 'Math.max(x, screen.availLeft)');
    shouldBe('window.screenY', 'Math.max(y, screen.availTop)');
    reset();



    // moveBy /////////////////////////
    debug('');
    debug('window.moveBy Tests');
    debug('');

    debug("Testing - moveBy with 0 arguments");
    shouldThrow('window.moveBy()');
    shouldBe('window.screenX', 'resetX');
    shouldBe('window.screenY', 'resetY');
    reset();

    debug("Testing - moveBy with 1 argument");
    shouldThrow('window.moveBy(x)');
    shouldBe('window.screenX', 'resetX');
    shouldBe('window.screenY', 'resetY');
    reset();

    debug("Testing - moveBy with more than 2 arguments");
    window.moveBy(x, y, 200, "text");
    shouldBe('window.screenX', 'resetX + x');
    shouldBe('window.screenY', 'resetY + y');
</script>
</body>
</html>
